﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Adex;
using MediaMonitor.Common;

namespace MediaMonitor.Admin{
public partial class Data_Mgmt_OD_Visibility : Adex.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void radGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable dt = Adex.Visibility.Query().SetSelectList("*, CONVERT(VARCHAR, DateModified, 101) AS LastModifiedDate ").ExecuteDataSet().Tables[0];
        radGrid.DataSource = dt;
    }

    protected void radGrid_DeleteCommand(Object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        string pkId = radGrid.MasterTableView.DataKeyValues[e.Item.ItemIndex]["VisibilityCode"].ToString();

        try
        {
            Visibility.Delete(pkId);

        }
        catch
        {
            AjaxFuncs.MsgBox(this, "Failed to delete this record, because related data (child records) exists in other tables");
        }

        radGrid.Rebind();
    }
}

}